package com.qf.bank.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.bank.employeeapi.api.EmployeeApi;
import com.qf.bank.employeeapi.po.Info;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 李成浩
 * @Date: 2019/12/7 17:59
 */
@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Resource
    private EmployeeApi employeeApi;

    /**
     * @param * @param null
     * @return
     * @auther 李成浩
     * @date 2019/12/9 14:46
     * 查询单个员工
     */
    @RequestMapping(value = "/{jobNumber}", method = RequestMethod.GET)
    Info getById(@PathVariable(value = "jobNumber") int jobNumber) {
        return employeeApi.getById(jobNumber);
    }

    /**
     * @param * @param null
     * @return
     * @auther 李成浩
     * @date 2019/12/9 15:05
     * 员工分页
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    Page<Info> page(@RequestParam int current, @RequestParam int size){
        return employeeApi.page(current,size);
    }

    /**
     * @param * @sparam null
     * @return
     * @auther 李成浩
     * @date 2019/12/9 15:09
     * 员工登陆验证
     */
    @RequestMapping(value = "/LoginTwo", method = RequestMethod.POST)
    Info getSelectLogin(@RequestBody Info info) {
        return employeeApi.getSelectLogin(info);
    }

    /**
     * @param * @param null
     * @return
     * @auther 李成浩
     * @date 2019/12/9 15:13
     * 添加一个员工
     */
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    boolean insert(@RequestBody Info info) {
        return employeeApi.insert(info);
    }

    /**
     * @param * @param null
     * @return
     * @auther 李成浩
     * @date 2019/12/9 15:15
     * 根据id删除一个员工
     */
    @RequestMapping(value = "/{jobNumber}", method = RequestMethod.DELETE)
    boolean getDeleteId(@PathVariable(value = "jobNumber") int jobNumber) {
        return employeeApi.getDeleteId(jobNumber);
    }

    /**
     * @param * @param null
     * @return
     * @auther 李成浩
     * @date 2019/12/9 15:20
     * 根据Id修改一个员工
     */
    @RequestMapping(value = "/", method = RequestMethod.PATCH)
    Boolean getChangeId(@RequestBody Info info) {
        return employeeApi.getChangeId(info);
    }

    /**
     * @param * @param null
     * @return
     * @auther 李成浩
     * @date 2019/12/9 15:22
     * 删除多个用户
     */
    @RequestMapping(value = "/", method = RequestMethod.DELETE)
    Boolean getDelete(@RequestBody List<Integer> list) {
        return employeeApi.getDelete(list);
    }
}
